import Attachment from './Attachment';
import Article from './Article';
import separate from '../patternSeparator';

separate('原型模式');

// 创建文章原型对象和克隆对象。
let appendix = new Attachment('报表', 'src://path/to/file');
let prototypeArticle = new Article(appendix); // 文章原型
prototypeArticle.setTitle('模板标题');
prototypeArticle.setContent('模板内容');

let yours = prototypeArticle.clone();
let mine = prototypeArticle.clone();

// 随意修改文章相关属性。
yours.setTitle('动物是如何入睡的');
mine.setTitle('行为艺术');
console.log(prototypeArticle);
console.log(yours);
console.log(mine);

// 随意修改附件实例。

let origAppendix = prototypeArticle.getAttachment();
let yourAppendix = yours.getAttachment();
origAppendix.setName('动物列表');
console.log(origAppendix);
console.log(yourAppendix);